#include "datamodel.h"

DataModel::DataModel(QObject *parent) :
    QAbstractTableModel(parent)
{
    m_data.push_back(Item(1,"http://123.com/2.jpg","c:\\test\\",0.13));
    m_data.push_back(Item(2,"http://microsoft.com/2.jpg","/var/lib/",0.90));
    m_data.push_back(Item(88,"http://google.com/myau.jpg","c:\\data\\",0.3));
}

int DataModel::rowCount(const QModelIndex &parent) const
{
    return m_data.size();
}

int DataModel::columnCount(const QModelIndex &parent) const
{
    return 4;
}

QVariant DataModel::data(const QModelIndex &index, int role) const
{
    if(role == Qt::DisplayRole )
    {
        switch(index.column())
        {
        case 0:
            return m_data[index.row()].id;
        case 1:
            return m_data[index.row()].url;
        case 2:
            return m_data[index.row()].local;
        case 3:
            return m_data[index.row()].percent;
        }
    }
    return QVariant();
}
